﻿using System;
using System.Windows.Forms;

namespace OpenShape
{
    public partial class LabelExpression : Form
    {

        public event Deligate_FieldExpression LabelExpression_FieldExpression;
        int index;

        public LabelExpression(int idx)
        {
            InitializeComponent();
            index = idx;
        }

        private void button1_Click(object sender, EventArgs e)
        {
            MessageBox.Show("사용자 라벨 표현식을 입력할 수 있습니다." + Environment.NewLine + Environment.NewLine + "    < 사  용  법 >" +
            Environment.NewLine + "원하시는 필드명은 위의 목록에서 더블 클릭하세요" + Environment.NewLine + "각 항목은 & 로 연결 하십시오" +
            Environment.NewLine + "사용자 문자는 \"로 묶어서 사용하십시오." + Environment.NewLine + Environment.NewLine + "    < 사  용  예 >" +
            Environment.NewLine + "입력시 : [필드명] & \"는 \" & [필드명]" + Environment.NewLine + "출력시 : A는 B");
        }

        private void LabelExpression_Load(object sender, EventArgs e)
        {
            for (int i = 0; i < LayerManager.m_Layers[index].m_DBF.pDataTable.Columns.Count; i++)
            {
                listBox1.Items.Add(LayerManager.m_Layers[index].m_DBF.pDataTable.Columns[i].ColumnName.ToString());
            }
        }

        private void listBox1_SelectedIndexChanged(object sender, EventArgs e)
        {
            textBox1.Text += "[" + listBox1.SelectedItem.ToString() + "]";
        }

        private void button2_Click(object sender, EventArgs e)
        {
            LabelExpression_FieldExpression(textBox1.Text);
            this.Dispose();
        }

        private void button3_Click(object sender, EventArgs e)
        {
            this.Dispose();
        }
    }
}
